const host = "http://127.0.0.1:3000"
import { data } from "autoprefixer"
import axios from "axios"

let token = localStorage.getItem("TOKEN");

// 用户注册
// http://127.0.0.1:3000/users/register
export const userRegister = (data = {}) => {
    return axios.post(`${host}/users/register`, data).then(response => response.data)
}

// 用户登录
// http://127.0.0.1:3000/users/login
export const userLogin = (data = {}) => {
    return axios.post(`${host}/users/login`, data).then(response => response.data)
}

// 获取轮播图列表
// http://127.0.0.1:3000/banner/list
export const getBanner = (data = {}) => {
    return axios.get(`${host}/banner/list`, { params: data }).then(response => response.data)
}

// 获取文章列表
// http://127.0.0.1:3000/article/list
export const getArtList = (data = {}) => {
    return axios.get(`${host}/article/list`, { params: data }).then(response => response.data)
}

// 获取导航列表
// http://127.0.0.1:3000/navs/list
export const getNavis = (data = {}) => {
    return axios.get(`${host}/navs/list`, { params: data }).then(response => response.data)
}

// 用户登录状态
// http://127.0.0.1:3000/users/online
export const userLoginFn = (data = {}) => {
    return axios.get(`${host}/users/online`, { params:data,headers:{token}}).then(response => response.data)
}

// 用户资料
// http://127.0.0.1:3000/users/get_user_info
export const userFn = (data = {}) => {
    return axios.get(`${host}/users/get_user_info`, { params:data,headers:{token}}).then(response => response.data)
}

// 添加收藏
// http://127.0.0.1:3000/like/add
export const addlikeFn = (data = {}) => {
    return axios.post(`${host}/like/add`, data,{headers:{token}}).then(response => response.data)
}

// 收藏列表
// http://127.0.0.1:3000/like/list
export const likeFn = (data = {}) => {
    return axios.post(`${host}/like/list`, data,{headers:{token}}).then(response => response.data)
}

// 删除收藏
// http://127.0.0.1:3000/like/remove
export const removelikeFn = (data = {}) => {
    return axios.post(`${host}/like/remove`, data,{headers:{token}}).then(response => response.data)
}

// 查看是否收藏
// http://127.0.0.1:3000/like/detail
export const islikeFn = (data = {}) => {
    return axios.post(`${host}/like/detail`, data,{headers:{token}}).then(response => response.data)
}

// 关键字搜索
// http://127.0.0.1:3000/article/search
export const searchFn = (data = {}) => {
    return axios.get(`${host}/article/search`,{ params: data }).then(response => response.data)
}

// 用户资料
// http://127.0.0.1:3000/users/set_user_info
export const setUserFn = (data = {}) => {
    return axios.post(`${host}/users/set_user_info`, data,{headers:{token}}).then(response => response.data)
}

